home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_12_1986_Transactor_Publishing.d64
/
kernal who.src1
< prev
next >
Wrap
Text File
|
2023-02-26
|
2KB
|
73 lines
; put "0:kernal who.src1"
;
; ********************************************************************
; program 1
; keyboard input routine using 'getin' and 'chrout' with 255 character
; buffer and automatic basic variable access. stores characters at
; $c000-$cfff. the first variable in the basic program should be a
; string (eg. a$=" "). when the program is called, this variable will
; contain the input. the length of input is controlled by the second
; variable declared by the basic program. this variable must be an
; integer (eg. a%=10) and have a value of 0-255.
; ********************************************************************
;
lda #$00 ; a zero in .a
sta $fe ; index storage
sta $cc ; flag to flash cursor
lda #$0a ; variable offset
lda ($2d),y ; get low byte of second var
sta $fd ; save it
;
loop jsr $ffe4 ; 'getin' go get a character
cmp #$00 ; is it a zero?
beq loop ; if zero then loop
;
cmp #$0d ; is it a return key?
beq end ; exit if return pressed
;
cmp #$14 ; is it a delete key?
bne nodel ; not delete then skip
;
ldy $fe ; buffer pointer
beq loop ; loop if buffer empty
;
dec $fe ; delete by decrementing pointer
jmp output ; jump output
;
nodel tax ; save .a in the .x register
and #$7f ; remove high bit from char
cmp #$20 ; is it a control character?
bcc loop ; is less than #$20 yes so loop
;
txa ; restore character to .a reg
ldy $fe ; retrieve buffer index
cpy $fd ; check if limit reached
bcs loop ; carry set, limit reached
;
inc $fe ; increment buffer pointer
bne put ; if buffer not full skip to 'put'
;
dec $fe ; oops, buffer full so back down one
jmp loop ; loop
;
put sta $c000,y ; place byte in $c000 buffer
;
output jsr $ffd2 ; 'chrout' - print the character
lda #$00 ; zero
sta $d4 ; disable quote mode
jmp loop ; play it again sam
;
end ldy #$02 ; offset to string variable length
lda $fe ; buffer pointer
sta ($2d),y ; put in first variable length byte
iny ; inc index y offset to pointer low byte
lda #$00 ; low order byte buffer location
sta ($2d),y ; store it in string variable pointer
iny ; increment index
lda #$c0 ; high order byte
sta ($2d),y ; store it in string variable pointer
inc $cc ; turn off cursor
lda #$20 ; a space to clear the cursor block
jsr $ffd2 ; print it
rts ; and return